package com.xtasz.itom.restfull.controller.workorder;


import com.xtasz.itom.util.Result;
import com.xtasz.itom.workorder.domain.WorkOrderFlow;
import com.xtasz.itom.workorder.service.inter.WorkOrderService;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by ZW on 2017/3/24.
 */

@Controller
@RequestMapping("/workOrderFlow")
public class WorkOrderFlowController {
    @Autowired
    private com.xtasz.itom.workorder.service.inter.WorkOrderService workOrderService;

    @RequestMapping(value = "/getWorkOrderList", method = RequestMethod.GET)
    @ResponseBody
    public Result<List<WorkOrderFlow>> getWorkOrderFlow() {
        Result<List<WorkOrderFlow>> result = new Result<List<WorkOrderFlow>>();
        List<WorkOrderFlow> list = workOrderService.getWorkOrderFlow();
        //JSONArray jsonArray =JSONArray.fromObject(list);

        //String jsonStr =jsonArray.toString();
        //WorkOrderFlow w =new WorkOrderFlow();
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
//            for(WorkOrderFlow workOrderFlow:list){
//                JSONObject jsonObject =new JSONObject();
//                jsonObject.put("sss", workOrderFlow.getISSEPERATE());
//
//            }
//            jsonArray=JSONArray.fromObject(list);
//            jsonStr=jsonArray.toString();
//            //JSONObject jo  = JSONObject.fromObject(jsonStr);

            //System.out.println(jsonStr);
            //System.out.println(jsonArray);
        }
        result.setData(list);
        return result;

    }


}
